package com.sjh.baseutils.bugly

import android.content.Context
import android.webkit.WebView
import com.tencent.bugly.crashreport.CrashReport

/**
 *@author : created by SunJH
 *时间：2021/6/7 000711
 *作用：bugly的初始化工具
 */
object BugReport {
    fun initBugly(context: Context,appId:String,isDebug:Boolean,channel:String = ""){
        val strategy = CrashReport.UserStrategy(context)
        strategy.appChannel = channel
        CrashReport.initCrashReport(context,appId,isDebug,strategy)
    }

    /**
     * 初始化监听JavaScript的报错
     * @param webView 要监听的对象
     * @param autoInject 是否自动注入 bugly.js文件
     */
    fun initJavaScriptBugReport(webView: WebView,autoInject: Boolean){
        CrashReport.setJavascriptMonitor(webView,autoInject)
    }
}
